﻿using Avalonia.Controls;
using Avalonia.Interactivity;
using ReactiveUI;

namespace LS.Screening.UI.Common.Mvvm
{
    public abstract class AbstractWindow : Window
    {
        public AbstractWindow()
        {
            //加载界面不应该有关闭等按钮，我们用 SystemDecorations=“None”。
            SystemDecorations = SystemDecorations.Full;

            //界面应该显示在屏幕正中间。我们用 WindowStartupLocation=“CenterScreen”。设置 WindowStartupLocation 为 "CenterScreen" 可以使窗口在屏幕上居中显示。
            WindowStartupLocation = WindowStartupLocation.CenterScreen;

            //改变窗口尺寸
            CanResize = false;
        }

        protected override void OnLoaded(RoutedEventArgs e)
        {
            base.OnLoaded(e);
        }

        protected override void OnUnloaded(RoutedEventArgs e)
        {
            base.OnUnloaded(e);
        }
    }

    public abstract class AbstractWindow<VM> : Window where VM : ViewModelBase
    {
        public AbstractWindow()
        {
            //加载界面不应该有关闭等按钮，我们用 SystemDecorations=“None”。
            SystemDecorations = SystemDecorations.Full;

            //界面应该显示在屏幕正中间。我们用 WindowStartupLocation=“CenterScreen”。设置 WindowStartupLocation 为 "CenterScreen" 可以使窗口在屏幕上居中显示。
            WindowStartupLocation = WindowStartupLocation.CenterScreen;

            //改变窗口尺寸
            CanResize = false;
            DataContext = CommonApplication.GetService<VM>();
        }

        protected override void OnLoaded(RoutedEventArgs e)
        {
            base.OnLoaded(e);
        }

        protected override void OnUnloaded(RoutedEventArgs e)
        {
            base.OnUnloaded(e);
        }
    }
}
